package com.iotteam.androidbase.moudules.sensor_history.view;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.iotteam.androidbase.R;
import com.iotteam.androidbase.base.ToolbarActivity;
import com.iotteam.androidbase.moudules.map.view.MapInfoActivity;
import com.iotteam.androidbase.moudules.sensor_detail.presenter.ISensorInfoPresenter;
import com.iotteam.androidbase.moudules.sensor_detail.presenter.SensorInfoPresenter;
import com.iotteam.androidbase.moudules.sensor_history.presenter.ISensorHistoryInfoPresenter;
import com.iotteam.androidbase.moudules.sensor_history.presenter.SensorHistoryInfoPresenter;

import org.w3c.dom.Text;

/**
 * Created by lidechen on 6/25/17.
 */

public class SensorHistoryInfoActivity extends ToolbarActivity implements ISensorHistoryInfoView {

    private ISensorHistoryInfoPresenter mPresenter;

    private RecyclerView mMainRecyclerView;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_sensor_history_info;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mMainRecyclerView = (RecyclerView) findViewById(R.id.rcv_main);
        mMainRecyclerView.setLayoutManager(new LinearLayoutManager(this));

        mPresenter = new SensorHistoryInfoPresenter(SensorHistoryInfoActivity.this);

        mPresenter.getSensorHistoryInfo();
    }

    public static void launch(Context context) {
        context.startActivity(new Intent(context, SensorHistoryInfoActivity.class));
    }

    @Override
    public void setAdapter(RecyclerView.Adapter adapter) {
        mMainRecyclerView.setAdapter(adapter);
    }

    @Override
    public void showLoading() {
        mWaitDialog.show();
    }

    @Override
    public void dismissLoading() {
        mWaitDialog.dismiss();
    }

    public static class HistoryInfoItemHolder extends RecyclerView.ViewHolder{

        public TextView terminalidText;
        public TextView tsText;
        public TextView posxText;
        public TextView posyText;
        public TextView anglesText;
        public TextView powerText;

        public HistoryInfoItemHolder(View itemView) {
            super(itemView);

            terminalidText = (TextView) itemView.findViewById(R.id.tv_terminalid);
            tsText = (TextView) itemView.findViewById(R.id.tv_ts);
            posxText = (TextView) itemView.findViewById(R.id.tv_posx);
            posyText = (TextView) itemView.findViewById(R.id.tv_posy);
            anglesText = (TextView) itemView.findViewById(R.id.tv_angles);
            powerText = (TextView) itemView.findViewById(R.id.tv_power);
        }
    }
}
